<template>
  <div class="app-container">

    <el-card style="border-radius: 10px">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
        <el-form-item label="客户名称" prop="clientName">
          <el-input
            v-model="queryParams.clientName"
            placeholder="请输入客户名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="产品名称" prop="itemName">
          <el-input
            v-model="queryParams.itemName"
            placeholder="请输入产品名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="销售员名称" prop="salesPerson">
          <el-input
            v-model="queryParams.salesPerson"
            placeholder="请输入销售员名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <div style="height: 15px"></div>
    <el-card style="border-radius: 10px">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['xs:return:statement:export']"
          >导出</el-button>
        </el-col>
      </el-row>

      <el-table
        v-loading="loading"
        stripe
        border
        :data="orderReturnList"
      >
        <el-table-column label="销售订单号" width="220" align="center" prop="soNumber" />
        <el-table-column label="客户名称" width="260" align="center" prop="clientName" :show-overflow-tooltip="true" />
        <el-table-column label="销售员" width="140" align="center" prop="salesPerson" />
        <el-table-column label="订单日期" width="140" align="center" prop="orderDate" />
        <el-table-column label="产品编码" width="200" align="center" prop="itemCode" />
        <el-table-column label="产品名称" width="260" align="center" prop="itemName" :show-overflow-tooltip="true" />
        <el-table-column label="退货数量" width="120" align="center" prop="returnNumber" />
        <el-table-column label="入库数量" width="120" align="center" prop="enterNumber" />
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>

<script>
import { listOrderReturnStatement } from "@/api/mes/xs/line";


export default {
  name: "orderReturnStatement",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品销售退货行表格数据
      orderReturnList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        salesPerson: null,
        itemName: null,
        clientName: null,
      },
    };
  },
  created() {
    this.getList();
  },

  methods: {
    /** 查询产品销售退货行列表 */
    getList() {
      this.loading = true;
      listOrderReturnStatement(this.queryParams).then(response => {
        this.orderReturnList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('/xs/line/returnExport', {
        ...this.queryParams
      }, `销售退货明细报表_${new Date().getTime()}.xlsx`)
    },

  }
};
</script>
